﻿using BusinessLogicLayer;
using Equin.ApplicationFramework;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PresentationLayer
{
    public partial class frmChiTietTangCa : Form
    {
        private TangCa ChiTietTangCa;
        public frmChiTietTangCa(TangCa tc)
        {
            InitializeComponent();
            ChiTietTangCa = tc;
            dgvDSDangKy.AutoGenerateColumns = false;
            dgvDSDangKy.DataSource = new BindingListView<DKTangCa>(ChiTietTangCa.DsDKTangCa);
            dtiNgayBatDau.Value = ChiTietTangCa.NgayBD;
            dtiNgayKetThuc.Value = ChiTietTangCa.NgayKT;
            dtiGioBatDau.Value = ChiTietTangCa.GioBatDau;
            dtiGioKetThuc.Value = ChiTietTangCa.GioKetThuc;
            txtMaTangCa.Text = ChiTietTangCa.MaTangCa;
            dtiNgayDangKy.MaxDate = tc.NgayKT;
            dtiNgayDangKy.MinDate = tc.NgayBD;
            dtiNgayDangKy.Value = DateTime.MinValue;
        }

        private void dtiNgayDangKy_Validated(object sender, EventArgs e)
        {
            
        }

        private void dtiNgayDangKy_ValueChanged(object sender, EventArgs e)
        {
            if (dtiNgayDangKy.Value == DateTime.MinValue)
                dgvDSDangKy.DataSource = new BindingListView<DKTangCa>(ChiTietTangCa.DsDKTangCa);
            else
            {
                List<DKTangCa> ds = ChiTietTangCa.DsDKTangCa.FindAll(s => s.NgayDangKy == dtiNgayDangKy.Value);
                dgvDSDangKy.DataSource = new BindingListView<DKTangCa>(ds);

            }
        }
    }
}
